<?php
$form = $this->beginWidget('CActiveForm', array(
    'id' => 'category-form',
    'enableAjaxValidation' => false,
    'enableClientValidation' => true,
    'htmlOptions' => array(
        'class' => 'form-horizontal',
        'enctype' => 'multipart/form-data',
    ),
        ));
?>
<div class="row-fluid">
    <div class="span12">
        <!--PAGE CONTENT BEGINS-->
        <?php
        $cate = MyFunctionCustom::getCategoryParent();
        //echo "<pre>";print_r($menu);
        if (count($cate) > 0):
            ?>
            <div class="control-group">
                <label class="control-label">Danh mục sản phẩm</label>
                <div class="controls">
                    <select id="product" name="Product[category_id]">
                        <option value="">--</option>
                        <?php
                        foreach ($cate as $k => $m) {
                            if ($k == $model['category_id']) {
                                echo "<option selected='selected' value='" . $k . "'>" . $cate[$k] . "</option>";
                            } else {
                                echo "<option value='" . $k . "'>" . $cate[$k] . "</option>";
                            }
                        }
                        ?>
                    </select>
                    <span class="help-inline"><?php echo $form->error($model, 'parent'); ?></span>
                </div>
            </div>                    
        <?php endif; ?>
        <div class="control-group">
            <label class="control-label">Tên sản phẩm</label>
            <div class="controls">
                <?php echo $form->textField($model, "name", array('size' => 60, 'maxlength' => 100, 'class' => 'span5', 'placeholder' => 'Tên menu')); ?>
                <span class="help-inline"><?php echo $form->error($model, 'name'); ?></span>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label">Hình Đại Diện</label>
            <div class="controls span4">
                <?php echo $form->fileField($model, 'cover_image', array('class' => 'id-input-file-1 span5')); ?>
                <span class="help-inline" style="float:left;margin-left:390px;"><?php echo $form->error($model, 'cover_image'); ?></span>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label"></label>
            <div class="controls"><img src="<?php echo Yii::app()->baseUrl; ?>/timthumb.php?src=<?php echo Yii::app()->baseUrl; ?>/data/cover/<?php echo $model->cover_image ?>&h=100&w=100" /></div>
        </div>
        <div class="control-group">
            <label class="control-label">Trạng thái</label>
            <div class="controls">
                <?php echo $form->dropDownlist($model, "active", array('0' => 'Ẩn', '1' => 'Hiện')); ?>
                <span class="help-inline"><?php echo $form->error($model, 'active'); ?></span>
            </div>
        </div>
        <div class="control-group" >
            <?php echo $form->labelEx($model, 'description', array('class' => 'control-label')); ?>
            <div class="controls">
                <span class="help-inline"><?php echo $form->error($model, 'description'); ?></span>
            </div>
        </div>       
        <?php
        $this->widget('ext.editMe.ExtEditMe', array(
//                                                          'name' => 'Cms[description_'.$key .']',
            'id' => 'description',
            'height' => '250px',
            'width' => '100%',
            'model' => $model,
            'attribute' => "description",
            'toolbar' => Yii::app()->params['ckeditor'],
            'filebrowserBrowseUrl' => Yii::app()->baseUrl . '/ckfinder/ckfinder.html',
            'filebrowserImageBrowseUrl' => Yii::app()->baseUrl . '/ckfinder/ckfinder.html?type=Images',
            'filebrowserFlashBrowseUrl' => Yii::app()->baseUrl . '/ckfinder/ckfinder.html?type=Flash',
            'filebrowserUploadUrl' => Yii::app()->baseUrl . '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
            'filebrowserImageUploadUrl' => Yii::app()->baseUrl . '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
            'filebrowserFlashUploadUrl' => Yii::app()->baseUrl . '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash',
        ));
        ?> 
        <div class="clear"></div>
        <div class="form-actions">
            <button class="btn btn-info" type="submit">
                <i class="icon-ok bigger-110"></i>
                Submit
            </button>
        </div>
        <!--PAGE CONTENT ENDS-->
    </div><!--/.span-->
</div><!--/.row-fluid-->    
<?php $this->endWidget(); ?>